import pathway as pw
from typing import Dict, Any, Optional

from application.db.mysql_db.info.ResourceInformationAttachmentList import ResourceInformationAttachmentList


class ResourceInformationAttachmentListSchema(pw.Schema):
    attachment_id: str
    information_id: Optional[str]
    attachment_name: str
    attachment_address: Dict[str, Any]
    display_order: int


class ResourceInformationAttachmentListRead(pw.io.python.ConnectorSubject):

    def run(self):
        select_list = ResourceInformationAttachmentList.select().dicts()
        for doc in select_list:
            self.next(**doc)